import 'package:flutter/material.dart';

import '../pages/LoginPage.dart';
import '../pages/HomePage.dart';
import '../pages/CatchPage.dart';
import '../pages/ServicesPage.dart';
import '../pages/AlarmPage.dart';
import '../pages/ValvePage.dart';
import '../pages/addDevices/SelectDevicesType.dart';
import '../pages/addDevices/InputDeviceNo.dart';

//配置路由
final routes = {
  '/': (context) => LoginPage(),
  '/home': (context) => HomePage(),
  '/catch': (context) => CatchPage(),
  '/services': (context) => ServicesPage(),
  '/selectDevicesType': (context) => SelectDevicesType(),
  '/InputDeviceNo': (context) => InputDeviceNo(),
  '/AlarmPage': (context) => AlarmPage(),
  '/ValvePage': (context) => ValvePage()
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
